package com.sixnimmt.app.client.game.view.dialog;

import com.google.gwt.event.dom.client.ClickEvent;
import com.google.gwt.event.dom.client.ClickHandler;
import com.google.gwt.user.client.ui.Button;
import com.google.gwt.user.client.ui.DialogBox;
import com.google.gwt.user.client.ui.DockPanel;
import com.google.gwt.user.client.ui.HasHorizontalAlignment;
import com.google.gwt.user.client.ui.HorizontalPanel;
import com.google.gwt.user.client.ui.Panel;
import com.google.gwt.user.client.ui.SimplePanel;
import com.google.gwt.user.client.ui.VerticalPanel;
import com.sixnimmt.app.client.i18n.SixNimmtMessages;

public class ScoreDialog extends DialogBox {

	private final Button closeButton;
	private final Panel mainPanel;

	public ScoreDialog(SixNimmtMessages messages) {
		super();

		this.setText(messages.finalScores());
		this.setVisible(true);
		this.setAnimationEnabled(true);
		this.setModal(true);

		mainPanel = new SimplePanel();

		HorizontalPanel hPanelButtons = new HorizontalPanel();
		closeButton = new Button(messages.close());
		hPanelButtons.add(closeButton);

		closeButton.addClickHandler(new ClickHandler() {
			@Override
			public void onClick(ClickEvent event) {
				ScoreDialog.this.close();
			}
		});

		DockPanel dPanelContent = new DockPanel();
		dPanelContent.add(mainPanel, DockPanel.CENTER);
		dPanelContent.add(hPanelButtons, DockPanel.SOUTH);
		dPanelContent.setCellHeight(hPanelButtons, "30px");
		dPanelContent.setCellHorizontalAlignment(hPanelButtons, HasHorizontalAlignment.ALIGN_RIGHT);
		dPanelContent.setCellVerticalAlignment(hPanelButtons, VerticalPanel.ALIGN_BOTTOM);

		this.setWidget(dPanelContent);
	}

	private void close() {
		hide();
	}

	public Panel getMainPanel() {
		return mainPanel;
	}

}
